package cn.b.sky.user.service.model;

import cn.b.sky.common.model.ImeCommon;
import cn.b.sky.common.model.TreeInterface;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * <strong>Title : ParameterFolder.java<br></strong>
 * <strong>Package : cn.b.sky.user.model<br></strong>
 * <strong>Description : </strong>参数目录<br> 
 * <strong>Create on : 2015-8-12 下午2:28:52<br></strong>
 * <p>
 * @author lidapeng<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人 | 修改日期 | 修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
public class ParameterFolder extends ImeCommon implements TreeInterface, Serializable {
  /** 
  * @Fields serialVersionUID : 实例化id
  * @creator     :lidapeng
  */
  private static final long serialVersionUID = -7537184726445366786L;

  /**
   * 目录编号
   */
  private String folderCode;

  /**
   * 目录描述
   */
  private String folderText;

  /**
   * 上级目录编号
   */
  private String parentFolderCode;

  /**
   * 显示顺序号
   */
  private Integer displayOrdinal = 0;

  /**
   * 是否叶子节点
   */
  private Boolean isLeaf = false;

  /**
   * 目录下面的参数
   */
  private List<ParameterEntity> parameters = new ArrayList<ParameterEntity>();

  /**
   * 子目录
   */
  private List<ParameterFolder> childrens;

  public String getFolderCode() {
    return StringUtils.upperCase(folderCode);
  }

  public void setFolderCode(String folderCode) {
    this.folderCode = StringUtils.upperCase(folderCode);
  }

  public String getFolderText() {
    return folderText;
  }

  public void setFolderText(String folderText) {
    this.folderText = folderText;
  }

  public String getParentFolderCode() {
    return parentFolderCode;
  }

  public void setParentFolderCode(String parentFolderCode) {
    this.parentFolderCode = parentFolderCode;
  }

  public Integer getDisplayOrdinal() {
    return displayOrdinal;
  }

  public void setDisplayOrdinal(Integer displayOrdinal) {
    this.displayOrdinal = displayOrdinal;
  }

  public List<ParameterEntity> getParameters() {
    return parameters;
  }

  public void setParameters(List<ParameterEntity> parameters) {
    this.parameters = parameters;
  }

  public List<ParameterFolder> getChildrens() {
    return childrens;
  }

  public void setChildrens(List<ParameterFolder> childrens) {
    this.childrens = childrens;
  }

  public Boolean getIsLeaf() {
    //当下面没有子目录和参数时则为叶子节点
    if ((this.childrens == null || this.childrens.size() <= 0) && parameters.size() <= 0) {
      this.isLeaf = true;
    }
    return isLeaf;
  }

  public void setIsLeaf(Boolean isLeaf) {
    this.isLeaf = isLeaf;
  }

  @Override
  public void setTrees(List trees) {
    this.childrens = trees;

  }

  @Override
  public String getPid() {

    return this.parentFolderCode;
  }

  @Override
  public String getNodeId() {
    return this.folderCode;
  }

}
